package com.vae.easternzhejiangbasin.controller;

import com.vae.easternzhejiangbasin.domain.ResponseResult;
import com.vae.easternzhejiangbasin.domain.dto.AddCommentDTO;
import com.vae.easternzhejiangbasin.service.CommentService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * @author LZH
 * @date 2023/
 * 3/6
 */
@CrossOrigin
@RestController
@RequestMapping("/comment")
public class CommentController {

    @Resource
    private CommentService commentService;

    @GetMapping("/pageList")
    public ResponseResult pageComment(Integer pageNum, Integer pageSize, Long experimentId) {
        return commentService.pageComment(pageNum, pageSize, experimentId);
    }

    @PostMapping
    public ResponseResult sendComment(@RequestBody AddCommentDTO addCommentDTO) {
        boolean result = commentService.sendComment(addCommentDTO);
        return ResponseResult.okResult(result);
    }

    @GetMapping("/article/{id}")
    public ResponseResult getCommentByCommentId(@PathVariable Long id) {
        return commentService.getCommentByCommentId(id);
    }
}
